import request from "../utils/request"
import qs from 'querystring';
//获取用户
export const getUsers=(data)=>{
    console.log('参数',data);
    return request.get(`/api/user`,{params:data})
}
//获取菜单
export const getMenu=()=>{
    return request.get('/api/menu')
}
//获取部门
export const getDept=()=>{
    return request.get('/api/dept')
}
//获取角色
export const getRole=(data)=>{
    return request.get('/api/role',{params:data})
}
//根据角色ID获取菜单
export const getMenuById=(id)=>{
    return request.get(`/api/role/menu/${id}`)
}
//新增用户
export const addUser=(data)=>{
  
    // console.log(qs.stringify(data));
    const res = request.post('/api/user',{data:qs.stringify(data)}) 
    // console.log(res);
    return res
}
//新增角色
export const addRole=(data)=>{
    return request.post('/api/role',{data:qs.stringify(data)})
}
//修改用户
export const updateUser=(data)=>{
 return  request.put('/api/user',{data:qs.stringify(data)})
}
//修改角色
export const updateRole=(data)=>{
    return request.put('/api/role',{data:qs.stringify(data)})
}
//删除用户
export const userDelete=(id)=>{
    return request.delete(`/api/user/${id}`)
}
//删除角色
export const roleDelete=(id)=>{
    return request.delete(`/api/role/${id}`)
}